package com.gomyb.admin.module.product.dao;

import com.gomyb.admin.module.product.model.AppProductRepertory;
import com.gomyb.common.base.BaseDao;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;

public interface AppProductRepertoryDao extends BaseDao<AppProductRepertory, Long> {

    @Modifying
    @Query(value = "update app_product_repertory\n" +
            "set count = count + ?1\n" +
            "where\n" +
            "  count = ?2\n" +
            "  and id = ?3", nativeQuery = true)
    int updateCount(BigDecimal count, BigDecimal oldCount, Long id);
}
